package com.webflux.demo.service.impl;

import com.webflux.demo.bean.User;
import com.webflux.demo.dao.UserRepository;
import com.webflux.demo.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;

/**
 * @author H
 * @date 2023/1/15
 */
@Service
public class UserServiceImpl implements UserService {

    @Autowired
    private UserRepository userRepository;

    @Override
    public Mono<User> getUserById(Long id) {
        return userRepository.findById(id);
    }

    @Override
    public Flux<User> getUserByUserName(String username) {
        return userRepository.findByUsernameLike(username);
    }

    @Override
    public Mono<User> insertUser(User user) {
        return userRepository.insert(user);
    }
}
